<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Checkbox Demo</title>
    <style>
        .message {
            padding: 10px;
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
            border-radius: 5px;
            margin-bottom: 20px;
        }
    </style>
</head>

<body>
    <div id="message" class="message">
        This is a message that can be dismissed for 5 days.
        <label>
            <input type="checkbox" id="dismiss-checkbox"> Do not show this message for 5 days
        </label>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function () {
            const messageDiv = document.getElementById('message');
            const checkbox = document.getElementById('dismiss-checkbox');
            const storageKey = 'dismissedMessage';

            // Check if the message has been dismissed and if the dismissal period has expired
            const dismissedData = localStorage.getItem(storageKey);
            if (dismissedData) {
                const { timestamp } = JSON.parse(dismissedData);
                const currentTime = new Date().getTime();
                const fiveDaysInMilliseconds = 5 * 24 * 60 * 60 * 1000;

                if (currentTime - timestamp < fiveDaysInMilliseconds) {
                    messageDiv.style.display = 'none';
                }
            }

            checkbox.addEventListener('change', function () {
                if (checkbox.checked) {
                    const dismissTimestamp = new Date().getTime();
                    const dismissData = { timestamp: dismissTimestamp };
                    localStorage.setItem(storageKey, JSON.stringify(dismissData));
                    messageDiv.style.display = 'none';
                }
            });
        });

    </script>
</body>

</html>